/*
 * @Author: fang quan
 * @Date: 2020-06-10 13:38:32 
 * @Last Modified by: fang quan
 * @Last Modified time: 2020-06-10 13:38:32 
 * @Usage 程序主入口
 */

import Vue from "vue";
import App from "./app.vue";
import router from "./router";
import store from "./store";
import config from "./config";
import create from "./utils/create";

import { formatParams } from "./utils/common";

import wx from "weixin-js-sdk";
import vconsole from "vconsole";

import "lib-flexible"; // root px相对值
import "./common/scss/main.scss"; // 全局样式

import VueClipboard from "vue-clipboard2"; //粘贴板
Vue.use(VueClipboard);

// ---- 按需引入VantUI ----
import { Toast, Notify, Image, Lazyload } from "vant";

Vue.use(Toast)
  .use(Notify)
  .use(Image)
  .use(Lazyload);

// ---- 常规配置 ----
Vue.config.productionTip = false;

window.wx = wx;
Vue.prototype.$config = config;
Vue.prototype.$toast = Toast;
Vue.prototype.$notify = Notify;

// debug 显示
if (formatParams().debug == 1) new vconsole();

// ---- 全局路由拦截器 ----
router.beforeEach((to, from, next) => {
  let { title = process.env.VUE_APP_BASE_TITLE } = to.meta;

  // 切换标题
  if (title) document.title = title;

  next();
})

// ---- 挂载 ----
create().then(() => {
  new Vue({
    router,
    store,
    render: (h) => h(App),
  }).$mount("#app");
});